package com.authine.cloudpivot.web.api.controller;

import com.authine.cloudpivot.web.api.controller.base.BaseController;
import com.authine.cloudpivot.web.api.service.UserService;
import com.authine.cloudpivot.web.api.view.ResponseResult;
import com.authine.cloudpivot.web.api.vo.User;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
/**
 * REST controller for managing hOrgUser.
 * @author chenjq
 */
@RestController
@RequestMapping("/api/user")
public class UsersController extends BaseController {

    private  Logger log = LoggerFactory.getLogger(User.class);

    @Autowired
    private  UserService userService;

    @GetMapping("/changPassword")
    public ResponseResult<?> getUserByUserAccout(String userId , String newPassword){
               String encode = PasswordEncoderFactories.createDelegatingPasswordEncoder().encode(newPassword);
               System.out.println("加密后密码"+encode);
               userService.update(userId,encode);
        return super.getOkResponseResult("密码修改成功");
    }
}
